// 引进axios
import axios from "axios";
// import { Indicator } from 'mint-ui';

const ajax = (options = {}, loading = true) => {

    // if (loading) {
    //     Indicator.open({
    //         text: '加载中...',
    //         spinnerType: 'fading-circle'
    //     });
    // }

    return axios(options)
        .then(results => {
            if (results.status === 200) {
                console.log('数据获取成功...');
                // if (loading) Indicator.close();
                return results.data;
            } else {
                console.log('数据获取失败...');
                // if (loading) Indicator.close();
                return {}
            }
        })
        .catch(error => {
            console.log('数据请求失败...', error);
            // if (loading) Indicator.close();
            return error;
        });
}

export default ajax;
